package com.cq.hd.common.enums.biz;

import lombok.Getter;

/**
 * @description: 订单状态(1 - 待支付, 2 - 待核销, 3 - 核销中, 4 - 已取消, 5 - 已完成, 6 - 已关闭, 7 - 已核销)
 * @author: mYunYu
 * @date: 2021/8/23 14:28
 * @version: v1.0
 */
public enum OrderStateEnum {

    WAIT_PAY(1, "待支付"),
    WAIT_VERIFY(2, "待核销"),
    VERIFYING(3, "核销中"),
    CANCEL(4, "已取消"),
    FINISH(5, "已完成"),
    CLOSE(6, "已关闭"),
    VERIFIED(7, "已核销"),
    PAYING(8, "支付中"),
    WAIT_AUDIT(9, "待审核"),
    WAIT_GROUP(10, "待成团")
    ;

    @Getter
    private final Integer value;

    @Getter
    private final String name;

    OrderStateEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static OrderStateEnum typeOf(Integer value) {
        OrderStateEnum[] values = OrderStateEnum.values();
        for (OrderStateEnum v : values) {
            if (v.value.equals(value)) {
                return v;
            }
        }
        return null;
    }

    public static OrderStateEnum typeOf(String name) {
        OrderStateEnum[] values = OrderStateEnum.values();
        for (OrderStateEnum v : values) {
            if (v.name.equals(name)) {
                return v;
            }
        }
        return null;
    }

}
